// 引入模块,创建接口
const express=require('express');
const pool=require('../pool.js');
const r=express.Router();

r.get('/categoryall',(req,res)=>{
	pool.query("select *  from xnlf",(err,result)=>{
		if(err) throw err;
		console.log(result)
		console.log('请求获取了模块参数数据表')
		res.send(result)
	})
})
r.get('/category',(req,res)=>{
	pool.query("select distinct cname from xnlf",(err,result)=>{
		if(err) throw err;
		console.log(result)
		console.log('请求获取了模块参数数据表')
		res.send(result)
	})
})
r.get('/subcat',(req,res)=>{
	let cname=req.query.cname;
	pool.query("select * from xnlf where cname = ? ",[cname],(err,result)=>{
		if(err) throw err;
		console.log(result)
		console.log('请求获取了模块参数数据表')
		res.send(result)
	})
})
r.get('/index',(req,res)=>{
	pool.query("select *from cloth",(err,result)=>{
		if(err) throw err;
		console.log('请求获取了模块参数数据表')
		res.send(result)
	})
})
r.get('/hot',(req,res)=>{
	pool.query("select * from cloth order by rand()",(err,result)=>{
		if(err) throw err;
		console.log('请求获取了模块参数数据表')
		res.send(result)
	})
})
r.get('/list',(req,res)=>{
	pool.query("select * from shopping_list",(err,result)=>{
		if(err) throw err;
		console.log('请求获取了模块参数数据表')
		res.send(result)
	})
})
r.get('/list1',(req,res)=>{
	pool.query("select * from shopping_list_xq",(err,result)=>{
		if(err) throw err;
		console.log('请求获取了模块参数数据表')
		res.send(result)
	})
})
r.get('/list2',(req,res)=>{  
	var lid=req.query.lid;
	console.log(lid)
	pool.query(`select * from shopping_lsit where lid=${lid}`,(err,result)=>{
		if(err) throw err;
		console.log(result)
		res.send(result)
	})
})



module.exports=r;
